<template>
  <div class="LoginBox">
    <el-card class="box-card">
      <template #header>
        <div class="card-header">
          <span class="card-span">修改密码</span>
        </div>
      </template>

      <el-form status-icon label-width="100px" class="demo-ruleForm">
        <el-form-item label="账号" prop="account">
          <el-input type="text" autocomplete="off" v-model="account" />
        </el-form-item>

        <el-form-item label="旧密码" prop="oldPassword">
          <el-input type="password" autocomplete="off" v-model="oldPassword" />
        </el-form-item>

        <el-form-item label="新密码" prop="password">
          <el-input type="password" autocomplete="off" v-model="newPassword" />
        </el-form-item>

        <el-form-item>
          <el-button type="primary" @click="changePassword">修改密码</el-button>
        </el-form-item>
      </el-form>
    </el-card>
  </div>
</template>

<script setup lang="ts">
import { changePSW } from "@/API/User.ts"
import {  ref } from "vue";
import { useRouter } from "vue-router";

let $router = useRouter()

let account = ref<string>("")
let oldPassword = ref<string>("")
let newPassword = ref<string>("")


let changePassword = () => {

  changePSW({
    account: account.value,
    oldPassword: oldPassword.value,
    password: newPassword.value,
    id: sessionStorage.getItem("userid")
  }).then(res => {
    console.log(res)
  })
}



</script>

<style scoped>
.LoginBox {
  height: 100%;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

.button,
.card-span {
  width: 50%;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.el-card__body {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
}

.el-button {
  width: 100%;
}

.text {
  font-size: 14px;
}

.item {
  margin-bottom: 18px;
}

.box-card {
  width: 480px;
}

.button {
  width: 100px;
}
</style>
